//
//  HXAllCagatoryTableViewCell.m
//  GiftSay
//
//  Created by laohu on 16/1/9.
//  Copyright © 2016年 liyinkai. All rights reserved.
//

#import "HXAllCagatoryTableViewCell.h"

@implementation HXAllCagatoryTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.image.frame = CGRectMake(10, 10, self.width - 20, self.height - 10);
    
    self.whiteLine.frame = CGRectMake(self.width / 10, self.height / 2 - 1, self.width / 5 * 4, 2);
    
    self.upLabel.frame = CGRectMake(self.width / 10, self.height / 4 - 1, self.width / 5 * 4, self.height / 4 );
    
    self.downLabel.frame = CGRectMake(self.width / 10, self.height / 2  + 1, self.width / 5 * 4, self.height / 4);
    
    self.halfBlack.frame = self.image.frame;
    
}

- (void)setModel:(HXTactikFirstModel *)model {
    [self.image setImageWithURL:[NSURL URLWithString:model.cover_image_url] placeholder:nil];
    self.upLabel.text = model.title;
    self.downLabel.text = model.subtitle;
    self.halfBlack.image = [UIImage imageNamed:@"bg.png"];
}

- (void)createView {
    self.image = [[UIImageView alloc] initWithFrame:CGRectZero];
    self.image.layer.cornerRadius = 5;
//    self.image.backgroundColor = [UIColor greenColor];
    [self addSubview:_image];
    
    self.whiteLine = [[UIView alloc] initWithFrame:CGRectZero];
    self.whiteLine.backgroundColor = [UIColor whiteColor];
    [self addSubview:_whiteLine];
    
    self.upLabel = [[HXLabelVerticalAlignment alloc] initWithFrame:CGRectZero];
    self.upLabel.textColor = [UIColor whiteColor];
//    self.upLabel.backgroundColor = [UIColor redColor];
    self.upLabel.textAlignment = NSTextAlignmentCenter;
    [self.upLabel setVerticalAlignment:VerticalAlignmentMiddle];
    [self addSubview:_upLabel];
    

    
    self.downLabel = [[HXLabelVerticalAlignment alloc] initWithFrame:CGRectZero];
    self.downLabel.textColor = [UIColor whiteColor];
    self.downLabel.textAlignment = NSTextAlignmentCenter;
    [self.downLabel setVerticalAlignment:VerticalAlignmentMiddle];
//    self.downLabel.backgroundColor = [UIColor redColor];
    [self addSubview:_downLabel];
    
    self.halfBlack = [[UIImageView alloc] initWithFrame:CGRectZero];
    [self addSubview:_halfBlack];
    
    
    
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
